#!/bin/bash
MYSQL_HOME='/usr/local'
if [[ -n  $(ps -ef |grep mysql|grep -v grep|grep -v sh) ]];then
	ps -ef |grep mysql|grep -v grep|grep -v sh|awk '{print $2}'|xargs kill -9
fi
echo "mysql process kill"
if [[ -n $(find /etc -name "my.cnf") ]];then
	rm -rf $(find /etc -name "my.cnf")
fi
if [[ -n $(find /etc -name "mysqld") ]];then
	rm -rf $(find /etc -name "mysqld")
fi
echo "/etc file delette"
if [[ -n $(find $MYSQL_HOME -name  "*mysql*") ]];then
	rm -rf $(find $MYSQL_HOME -name  "*mysql*")
fi
if [[ $(tail -n 1 /etc/profile) =~ $MYSQL_HOME/mysql/bin ]];then
	sed -i '$d' /etc/profile
fi
echo "/etc/profile del"
if [[ -n $(cat /etc/passwd |grep mysql) ]];then
	userdel mysql
fi
echo "user mysql del"
if [[ -n $(chkconfig --list |grep mysql) ]];then
	chkconfig --del mysqld
fi
echo "chkconfig mysql del"
